package com.ants.boot.wx.service.impl;

import com.ants.boot.system.domain.SysUser;
import com.ants.boot.wx.dao.WxSelfSetMapper;
import com.ants.boot.wx.dto.selfset.WxEditAgeDto;
import com.ants.boot.wx.dto.selfset.WxEditEmailDto;
import com.ants.boot.wx.dto.selfset.WxEditNicknameDto;
import com.ants.boot.wx.dto.selfset.WxEditSexDto;
import com.ants.boot.wx.service.WxSelfSetService;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * @author 蚂蚁会花呗
 * @date 2022/5/27 16:27
 */
@Service
public class WxSelfSetServiceImpl extends ServiceImpl<WxSelfSetMapper, SysUser> implements WxSelfSetService {
    @Override
    public boolean editNickname(WxEditNicknameDto dto) {
        UpdateWrapper<SysUser> updateWrapper = new UpdateWrapper<>();
        updateWrapper.lambda()
                .eq(SysUser::getId,dto.getId())
                .set(SysUser::getNickName,dto.getNickName());
        return this.update(updateWrapper);
    }

    @Override
    public boolean editSex(WxEditSexDto dto) {
        UpdateWrapper<SysUser> updateWrapper = new UpdateWrapper<>();
        updateWrapper.lambda()
                .eq(SysUser::getId,dto.getId())
                .set(SysUser::getSex,dto.getSex());
        return this.update(updateWrapper);
    }

    @Override
    public boolean editAge(WxEditAgeDto dto) {
        UpdateWrapper<SysUser> updateWrapper = new UpdateWrapper<>();
        updateWrapper.lambda()
                .eq(SysUser::getId,dto.getId())
                .set(SysUser::getAge,dto.getAge());
        return this.update(updateWrapper);
    }

    @Override
    public boolean editEmail(WxEditEmailDto dto) {
        UpdateWrapper<SysUser> updateWrapper = new UpdateWrapper<>();
        updateWrapper.lambda()
                .eq(SysUser::getId,dto.getId())
                .set(SysUser::getEmail,dto.getEmail());
        return this.update(updateWrapper);
    }
}
